%%%-------------------------------------------------------------------
%%% File    : pgt.hrl
%%% Author  :  <vjache>
%%% Description : Process Group Tree 
%%%
%%% Created : 13 Jan 2009 by  <vjache>
%%%-------------------------------------------------------------------

%% -define(TIMEOUT,4000000).
-define(PARENT_PG,get(parent_pg_pid)).
-define(PG,get(pg_pid)).

-define(FINISH_MSG,{finish,?PG}).

%%%-------------------------------------------------------------------
%%% Record: #pg{id,name,pgs,workers}
%%% Description: This is a descriptor of a process group (PG). Actually 
%%%				 it descibes a tree of process groups. Each PG may have
%%%				 a set of worker processes (WPs). When all child  PGs
%%%				 have exited normaly PG notify all its WPs about that (
%%%				 they can use or not this notification for their 
%%%				 finalization logic). PG decide to exit if an only if 
%%%				 its all child PGs and WPs have exited. Entire tree of 
%%%				 PGs and WPs is linked, so if some process exits abnormally 
%%%				 then whole tree dies.
%%%				 id - unique identifier of a PG
%%%				 name - a human readable name of a PG
%%%				 pgs - a child process groups list: [pg()]
%%%				 workers - a fun that contains a code spawning 
%%%				 initial worker processes in this PG: fun()->term(), or 
%%%				 a list of worker descriptors:[#worker].
%%%-------------------------------------------------------------------
-record(pg,{id=make_ref(),name="Process group",pgs=[],workers=null}).
%%%-------------------------------------------------------------------
%%% Record: #worker{id,launch_spec}
%%% Description: This is a worker specification that used in API of
%%% 			 pgt module.
%%%				 id - identifier unique in sope of PG this work belongs to
%%%				 spawn_spec - this is a complete spawn specification that 
%%%				 			  describes how an where to spawn WP. It is a 
%%%							  tuple with the structure:
%%%								{WorkFun}|
%%%								{Node, WorkFun}|
%%%								{Module, Function, Args}|
%%%								{Node, Module, Function, Args}.
%%%-------------------------------------------------------------------
-record(worker,{id=make_ref(),spawn_spec}).
